var gulp = require('gulp')
var connect = require('gulp-connect')
var modRewrite = require('connect-modrewrite')
var config = require('../config').des
var proxyMiddleware = require('http-proxy-middleware')

var middleware = proxyMiddleware(['/api5'], {
  target: 'http://h5.qpbaba.com/api5',
  changeOrigin: true,
  pathRewrite: {
    '^/api5': '/',
  },
})

gulp.task('connect', function() {
  connect.server({
    root: config.dest,
    port: 9002,
    https: false,
    host: '0.0.0.0',
    livereload: {
      start: true,
      port: 35735,
    },
    middleware: function(connect, o) {
      return [middleware]
    },
  })
})
